﻿using System;
using System.Collections;
using System.ComponentModel;


namespace BizElements.BusinessLayer
{
    /// <summary>
    /// Value-name datasource.
    /// </summary>
    public interface ICodeList : IListSource
    {
        #region Methods.

        /// <summary>
        /// Creates data source index which significantly enhances the performance of <see cref="GetDisplayValue"/> method.
        /// </summary>
        void CreateIndex();

        /// <summary>
        /// Gets the display value associated with the specified key value.
        /// </summary>
        /// <param name="key">Value stored in the data source's key field.</param>
        /// <returns>Display value or <b>null</b> if the given key field is not found in the code list.</returns>
        object GetDisplayValue(object key);

        #endregion

        #region Properties.

        /// <summary>
        /// Data source field which provides a key value.
        /// </summary>
        string ValueMember { get; }

        /// <summary>
        /// Data source field which provides a display value.
        /// </summary>
        string DisplayMember { get; }

        /// <summary>
        /// Data source wrapped by in the current <b>CodeList</b>.
        /// </summary>
        IList DataSource { get; }

        #endregion
    }
}